<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%@ page import="java.sql.*,java.util.*,init.*,com.skku.selab.erp.db.sql.*,com.skku.selab.erp.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="com.skku.selab.erp.job.schduler"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
	DBConnectionMgr pool = null;
	Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    ResultSetMetaData rsmd = null;
    QueryResultSet qrs = new QueryResultSet();
    
    int reInt = 0;
    
    //erpDBQueries erp = new erpDBQueries();
    
	try {	    
		Properties props = new Properties();
        
		out.println("<p>Start<p>");
	
		props.put("user", "root");
	    props.put("password", "7220");
        
        con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/gache?useUnicode=true&characterEncoding=EUC_KR", props);

        
        //DML.deleteFrom(con, "product", "idPRODUCT='3'");
        /*
        if( (reInt = DML.updateTable(con, "employee", "name = \"KimJunhee2\"", "idEmployee = 1")) 
        		!= -1 ){
        	rs = DML.selectFrom(con, "*", "employee");
        	while(rs.next()){
        		out.println( "<p>" + rs.getString(1) + "\t" + rs.getString(2)
        				+ "\t" + rs.getString(3));
        	}
        }
        */
        //Iterator<Tuple> iter;
        //iter = TupleTable.getEntireTable(con, "gache_erp").iterator();
        //Iterator<Tuple> iter = TupleTable.getEntireTable(con, "gache_erp").iterator();
        Iterator<Tuple> iter = TupleTable.getEntireTable(con, "gache_erp").iterator();
        Tuple tempTuple = new Tuple();
        int i=0;
        while( iter.hasNext() ){
        	//tempTuple = iter.next();
        	//out.println(tempTuple.address_1 + tempTuple.address_2);
        	i++;
        	tempTuple = iter.next();
        	out.println(i + " :   " + tempTuple.idx + "   " + tempTuple.member_id + "   " + tempTuple.email + "<p>");
        	//out.println(tempTuple. + "<p>");
        }
        
        tempTuple.idx = "1";
        tempTuple.member_id = "2";
        tempTuple.password = "3";
        tempTuple.name = "4";
        tempTuple.social_number = "5";
        tempTuple.post_number = "6";
        tempTuple.address_1 = "7";
        tempTuple.address_2 = "8";
        tempTuple.contact = "9";
        tempTuple.email = "10";
        tempTuple.shop_name = "11";
        tempTuple.shop_business_number = "12";
        tempTuple.shop_post_number = "13";
        tempTuple.shop_address_1 = "14";
        tempTuple.shop_address_2 = "15";
        tempTuple.shop_phone_number = "16";
        tempTuple.shop_representative = "17";
        tempTuple.shop_representative_phone = "18";
        tempTuple.shop_email = "19";
        tempTuple.shop_homepage = "20";
        tempTuple.shop_kind = "21";
        tempTuple.shop_history = "22";
        tempTuple.shop_size = "23";
        tempTuple.target_year = "24";
        tempTuple.target_taste = "25";
        tempTuple.target_cost_0 = "26";
        tempTuple.target_cost_1 = "27";
        tempTuple.target_cost_2 = "28";
        tempTuple.target_cost_3 = "29";
        tempTuple.target_cost_4 = "30";
        tempTuple.target_sourcing_0 = "31";
        tempTuple.target_sourcing_1 = "32";
        tempTuple.sign_in_date = "2010-10-10";
        tempTuple.modified_date = "2010-10-10";
        
        out.println(TupleTable.insertTuple(con, "gache_erp", tempTuple));
        
        out.println("HI");
        
        
        /*
        if( DML.insertInto(con, "product", "(3, 'Amber', 10000)") != -1 ){
        	rs = DML.selectFrom(con, "*", "product");
            while(rs.next()){
            	out.println( "<p>" + rs.getString(1) + "\t" + rs.getString(2)
            			+ "\t" + rs.getString(3));
            }        
        }
        
        out.println("<p>Inserted");
        */
        /*
        out.println("<p>By Using DefaultQueries.executeQuery method<p>");
        rs = DefaultQueries.executeQuery(con, "select * from employee");
        while(rs.next()){
        	out.println( "<p>" + rs.getString("idEmployee") + "\t"
        			+ rs.getString("name") + "\t" + rs.getString("phone"));
        }
        
        out.println("<p>By Using QueryResultSet instance<p>");
        qrs.query(con, "select * from employee");
        if( qrs.isResultSetReturn() )
        	while(qrs.getResultSet().next()){
        		out.println( "<p>" + qrs.getResultSet().getString("idEmployee")
        				+ "\t" + qrs.getResultSet().getString("name")
        				 + "\t"+ qrs.getResultSet().getString("phone"));
        	}
        else
        	out.println("return is not ResultSet type<p>");
        
        out.println("<p>By Using DML.selectFrom method<p>");
        rs = DML.selectFrom(con, "*", "employee");
        while(rs.next()){
        	out.println( "<p>" + rs.getString("name"));
        }
        */
        
        //out.println("<p>drop table : testtable<p>");
        
        //reInt = DDL.dropTable(con, "testtable");
        //out.println(reInt);
        //rs = DML.selectFrom(con, "*", "employee");
        //while (rs.next()) {
        //	out.println("ID:"+rs.getString(1));
		//}	
        //pstmt = con.prepareStatement("select * from employee");
        //ResultSet rs = pstmt.executeQuery();		
        //while (rs.next()) {
        //	out.println("ID:"+rs.getString("USER_ID"));
		//}	
        
        /*
        qrs.query(con, "SELECT * FROM employee");
        
        if(qrs.isResultSetReturn())
        {
        	while(qrs.getResultSet().next())
        		out.println( "<p>" + qrs.getResultSet().getString(1) + " " + qrs.getResultSet().getString(2) + " " + qrs.getResultSet().getString(3));
        }
        
        out.println("<P>");
        
        qrs.query(con, "update employee set name = \"KimJunhee5\" where idEmployee = 1");
        if(!qrs.isResultSetReturn())
        {
        	out.println("<p>" + qrs.getIntResult());
        }
        */
        
        /*

        rs = DefaultQueries.executeQuery(con, "select * from employee");
        while(rs.next()){
        	out.println( "<p>" + rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3));
        }
        out.println("<p>");
        
        schduler.setSchduler(con, true);

        */
        //DML.updateTable(con, "product", "price = 50000", "price = 5000 AND prdtName = \"Pearl\"");
        //if( TCL.savepoint(con, "A") != null )
        //	out.println("Done<p>");
        
        
        
        //DML.insertInto(con, "product", "(2, 'Silver', 10000)");
        
        /*
        reInt = DML.updateTable(con, "employee", "name = \"KimJunhee2\"", "idEmployee = 1");
        out.println(reInt);
        rs = DefaultQueries.executeQuery(con, "select * from employee");
        while(rs.next()){
        	out.println( "<p>" + rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3));
        }
        out.println("<p>");
        */
        //rs = DML.update(con, "employee", "name = \"KimJunhee2\"", "idEmployee = 1");
        //rs = DefaultQueries.executeAnyQuery(con, "update employee)
        //rs = DefaultQueries.executeAnyQuery(con, "select * from employee");
        //while(rs.next()){
        //	out.println( "<p>" + rs.getString(1) + " " + rs.getString(2) + " " + rs.getString(3));
        //}
        //out.println("<p>");
        
        
        
        //rs = DefaultQueries.executeAnyQuery(con, "select * from employee");
        //ResultSetMetaData rsmd = rs.getMetaData();
        //out.println("<p>colums : " + rsmd.getColumnCount());
        //while(rs.next()){
        	
        //}        
	}	catch(Exception ex)	{
		System.out.println("Exception" + ex);
	}	finally	{
		if(con!=null)	con.close();
		if(rs!=null)	rs.close();
		if(pstmt!=null)	pstmt.close();
	}
	out.println("<p>End<p>");
%>
</body>
</html>